using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DreamBuilder.DictionaryAccess;



namespace DreamBuilder.UI.UserControls
{
    public partial class UCListSelect : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {

            string id = Request.QueryString["ID"];
            System.Collections.Generic.List<CVoucherListItemInfo> listItems = DictionaryAccessFacade.GetSortedListItemsInfo(id);
            listItems.ForSpecification<CVoucherListItemInfo>(
                delegate(CVoucherListItemInfo voucherListItemInfo)
                {
                    ListItem listItem = new ListItem(DictionaryAccessFacade.GetFieldResDicInfo(voucherListItemInfo.TableCode, voucherListItemInfo.FieldCode).FieldDesc, voucherListItemInfo.ItemCode);
                    ListSource.Items.Add(listItem);
                },
                delegate(CVoucherListItemInfo listItemInfo)
                {
                    return listItemInfo.Show == true ? true : false;
                }
                );
        }

        protected void ListSource_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (ListSource.SelectedIndex > -1 && !ListResult.Items.Contains(ListSource.SelectedItem))
            {
                ListResult.Items.Add(ListSource.SelectedItem);
                ListSource.Items.Remove(ListSource.SelectedItem);
            }
        }

        protected void btnDel_Click(object sender, EventArgs e)
        {
            if (ListResult.SelectedIndex > -1 && !ListSource.Items.Contains(ListResult.SelectedItem))
            {
                ListSource.Items.Add(ListResult.SelectedItem);
                ListResult.Items.Remove(ListResult.SelectedItem);
            }
        }

        protected void btnConfirm_Click(object sender, EventArgs e)
        {

        }

        protected void BtnClose_Click(object sender, EventArgs e)
        {

        }
    }
}
